/**
 */
package de.thwildau.tm.moses.avro.avdl.impl;

import de.thwildau.tm.moses.avro.avdl.AvdlPackage;
import de.thwildau.tm.moses.avro.avdl.AvroIdl;
import de.thwildau.tm.moses.avro.avdl.NamespaceAnnotation;
import de.thwildau.tm.moses.avro.avdl.Protocol;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Avro Idl</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.thwildau.tm.moses.avro.avdl.impl.AvroIdlImpl#getNameSpace <em>Name Space</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.avro.avdl.impl.AvroIdlImpl#getProtocol <em>Protocol</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class AvroIdlImpl extends MinimalEObjectImpl.Container implements AvroIdl
{
  /**
   * The cached value of the '{@link #getNameSpace() <em>Name Space</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getNameSpace()
   * @generated
   * @ordered
   */
  protected NamespaceAnnotation nameSpace;

  /**
   * The cached value of the '{@link #getProtocol() <em>Protocol</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getProtocol()
   * @generated
   * @ordered
   */
  protected Protocol protocol;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected AvroIdlImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return AvdlPackage.Literals.AVRO_IDL;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NamespaceAnnotation getNameSpace()
  {
    return nameSpace;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetNameSpace(NamespaceAnnotation newNameSpace, NotificationChain msgs)
  {
    NamespaceAnnotation oldNameSpace = nameSpace;
    nameSpace = newNameSpace;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AvdlPackage.AVRO_IDL__NAME_SPACE, oldNameSpace, newNameSpace);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setNameSpace(NamespaceAnnotation newNameSpace)
  {
    if (newNameSpace != nameSpace)
    {
      NotificationChain msgs = null;
      if (nameSpace != null)
        msgs = ((InternalEObject)nameSpace).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AvdlPackage.AVRO_IDL__NAME_SPACE, null, msgs);
      if (newNameSpace != null)
        msgs = ((InternalEObject)newNameSpace).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AvdlPackage.AVRO_IDL__NAME_SPACE, null, msgs);
      msgs = basicSetNameSpace(newNameSpace, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AvdlPackage.AVRO_IDL__NAME_SPACE, newNameSpace, newNameSpace));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Protocol getProtocol()
  {
    return protocol;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetProtocol(Protocol newProtocol, NotificationChain msgs)
  {
    Protocol oldProtocol = protocol;
    protocol = newProtocol;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AvdlPackage.AVRO_IDL__PROTOCOL, oldProtocol, newProtocol);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setProtocol(Protocol newProtocol)
  {
    if (newProtocol != protocol)
    {
      NotificationChain msgs = null;
      if (protocol != null)
        msgs = ((InternalEObject)protocol).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AvdlPackage.AVRO_IDL__PROTOCOL, null, msgs);
      if (newProtocol != null)
        msgs = ((InternalEObject)newProtocol).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AvdlPackage.AVRO_IDL__PROTOCOL, null, msgs);
      msgs = basicSetProtocol(newProtocol, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AvdlPackage.AVRO_IDL__PROTOCOL, newProtocol, newProtocol));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case AvdlPackage.AVRO_IDL__NAME_SPACE:
        return basicSetNameSpace(null, msgs);
      case AvdlPackage.AVRO_IDL__PROTOCOL:
        return basicSetProtocol(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case AvdlPackage.AVRO_IDL__NAME_SPACE:
        return getNameSpace();
      case AvdlPackage.AVRO_IDL__PROTOCOL:
        return getProtocol();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case AvdlPackage.AVRO_IDL__NAME_SPACE:
        setNameSpace((NamespaceAnnotation)newValue);
        return;
      case AvdlPackage.AVRO_IDL__PROTOCOL:
        setProtocol((Protocol)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case AvdlPackage.AVRO_IDL__NAME_SPACE:
        setNameSpace((NamespaceAnnotation)null);
        return;
      case AvdlPackage.AVRO_IDL__PROTOCOL:
        setProtocol((Protocol)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case AvdlPackage.AVRO_IDL__NAME_SPACE:
        return nameSpace != null;
      case AvdlPackage.AVRO_IDL__PROTOCOL:
        return protocol != null;
    }
    return super.eIsSet(featureID);
  }

} //AvroIdlImpl
